<template>
  <div class="list">
      <button @click="saveA(520)">a: {{a}}</button>
  </div>
</template>

<script>
import { mapGetters, mapMutations, mapState } from "vuex";
export default {
    data() {
        return {
            a: this.$store.state.List.a
        }
    },
    methods: {
        ...mapMutations(['saveA']), //点击按钮,触发这个mutations事件
    },
    mounted() {
        console.log("a",this.a);
    },
    computed:{
        // mapGetters: 监听list.js文件中 state.a的变化
        ...mapGetters([
            'getListA'
        ])
    },
    watch: {
        getListA: function(a){
            this.a = a;
        }
    }
}
</script>

<style lang="scss" scoped>

</style>